﻿Imports XL.Common
Imports XL.Common.Utils
Imports XL.Win
Imports XL.Win.Utils

Namespace Utils

    Public Class Login
        Inherits XL.Win.Window.BaseLoginForm


#Region " Windows auto generated code"

        Public Sub New()
            MyBase.New()

            '该调用是 Windows 窗体设计器所必需的。
            InitializeComponent()

            '在 InitializeComponent() 调用之后添加任何初始化

        End Sub

        '窗体重写 dispose 以清理组件列表。
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
        Private components As System.ComponentModel.IContainer

        'Windows 窗体设计器所必需的

        '注意: 以下过程是 Windows 窗体设计器所必需的
        '可以使用 Windows 窗体设计器修改此过程。
        '不要使用代码编辑器修改它。
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents Label4 As System.Windows.Forms.Label
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.Label4 = New System.Windows.Forms.Label
            CType(Me.TextEdit_Password.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.CheckEdit_SavePassword.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.ComboBoxEdit_Account.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.Panel_AccountPart.SuspendLayout()
            Me.SuspendLayout()
            '
            'Label_Title
            '
            Me.Label_Title.Visible = False
            '
            'TextEdit_Password
            '
            '
            'CheckEdit_SavePassword
            '
            '
            'ComboBoxEdit_Account
            '
            '
            'Label_Clock
            '
            Me.Label_Clock.Size = New System.Drawing.Size(164, 27)
            Me.Label_Clock.Text = "2010/09/01  07:58:53"
            '
            'Panel_AccountPart
            '
            Me.Panel_AccountPart.Size = New System.Drawing.Size(584, 124)
            '
            'Label4
            '
            Me.Label4.BackColor = System.Drawing.Color.Transparent
            Me.Label4.Font = New System.Drawing.Font("SimHei", 21.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
            Me.Label4.Location = New System.Drawing.Point(152, 136)
            Me.Label4.Name = "Label4"
            Me.Label4.Size = New System.Drawing.Size(272, 32)
            Me.Label4.TabIndex = 11
            Me.Label4.Text = "Sub System Title"
            Me.Label4.TextAlign = System.Drawing.ContentAlignment.TopCenter
            '
            'Login
            '
            Me.AcceptButton = Me.SimpleButton_Login
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.BackColor = System.Drawing.Color.WhiteSmoke
            Me.ClientSize = New System.Drawing.Size(584, 349)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
            Me.MinimizeBox = False
            Me.Name = "Login"
            Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
            CType(Me.TextEdit_Password.Properties, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.CheckEdit_SavePassword.Properties, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.ComboBoxEdit_Account.Properties, System.ComponentModel.ISupportInitialize).EndInit()
            Me.Panel_AccountPart.ResumeLayout(False)
            Me.Panel_AccountPart.PerformLayout()
            Me.ResumeLayout(False)
            Me.PerformLayout()

        End Sub

#End Region

        Protected Overrides Sub DoInitialize()

            WinDecl.UPGRADE_FILE_LIST.Add("RExpClient.Exe")
            WinDecl.UPGRADE_FILE_LIST.Add("RExpXAuto.dll")
            WinDecl.UPGRADE_FILE_LIST.Add("RExpXService.dll")
            WinDecl.UPGRADE_FILE_LIST.Add("InfoCentreXAuto.dll")
            WinDecl.UPGRADE_FILE_LIST.Add("InfoCentreXService.dll")
            WinDecl.UPGRADE_FILE_LIST.Add("XL.Common.dll")
            WinDecl.UPGRADE_FILE_LIST.Add("XL.DB.dll")
            WinDecl.UPGRADE_FILE_LIST.Add("XL.Win.dll")
            WinDecl.UPGRADE_RELAUNCH_FILENAME = "RExpClient"
            SysInfo.SYS_LM = 4000

            If XL.Common.CommDecl.SYSTEM_MODE <> SystemModes.StandardNoDB AndAlso _
               XL.Common.CommDecl.SYSTEM_MODE <> SystemModes.StandardNoDBNoLogin AndAlso _
               XL.Common.CommDecl.SYSTEM_MODE <> SystemModes.Demo Then

                XL.Common.Utils.SysInfo.SetShareTRSysInfo(AddressOf RExpXService.Facade.OpSysConfig.GetSysValue, AddressOf RExpXService.Facade.OpSysConfig.SetSysValue)


                RExpXAuto.XDB.DBInitializor.InitCommonItemTableFields()
                RExpXAuto.TK.SetUniqueContraints()
                RExpXAuto.XDB.DBInitializor.InitBelongTableFields()

                XL.DB.DBDecl.InUseInfoDeletable = True

            End If

            WinTK.RegisterRemoteType(GetType(RExpXService.ServiceTK))
 
            RExpXAuto.Decls.LOCAL_CACHE_DATA_PATH = WinTK.GetResourceFilePath(ResourceType.Data, String.Empty)


            System.Runtime.Remoting.RemotingConfiguration.CustomErrorsMode = System.Runtime.Remoting.CustomErrorsModes.Off
            System.Runtime.Remoting.RemotingConfiguration.CustomErrorsEnabled(False)

        End Sub

        Protected Overrides Sub BeforeLogin()

            Utils.TK.InitDefaultData()


            'Utils.Decls.INFOCENTRE_SERVICE_TK = InfoCentreXService.ServiceTK_IC.GetInstance
            'XL.Win.XForm.XFormTK.SetTRDoHandshake(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.DoHandshake)
            'XL.Win.XForm.XFormTK.SetTRSaveService(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.SaveService)
            'XL.Win.XForm.XFormTK.SetTRSendSMSMessage(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.SendSMSMessage)
            'XL.Win.XForm.XFormTK.SetTRFillServiceRowSEByCode(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceRowSEByCode)
            'XL.Win.XForm.XFormTK.SetTRFillServiceServItemList(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceServItemList)
            'XL.Win.XForm.XFormTK.SetTRFillServiceServItemChargeList(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceServItemChargeList)
            'XL.Win.XForm.XFormTK.SetTRFillServiceFeeRechargeList(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceFeeRechargeList)
            'XL.Win.XForm.XFormTK.SetTRFillServiceSMSSentList(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceSMSSentList)
            'XL.Win.XForm.XFormTK.SetTRFillServiceLabelOrderList(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceLabelOrderList)
            'XL.Win.XForm.XFormTK.SetTRFillServiceLabelUsageList(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceLabelUsageList)
            'XL.Win.XForm.XFormTK.SetTRUploadLabelPrintHistory(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.UploadLabelPrintHistory)
            'XL.Win.XForm.XFormTK.SetTRSaveLabelOrder(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.SaveLabelOrder)
            'XL.Win.XForm.XFormTK.SetTRFillSoftlandsSystemRowSE(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillSoftlandsSystemRowSE)
            'XL.Win.XForm.XFormTK.SetTRFillServiceServItemRowSE(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceServItemRowSE)
            'XL.Win.XForm.XFormTK.SetTRAlterServiceInfo(AddressOf Utils.Decls.INFOCENTRE_SERVICE_TK.AlterServiceInfo)

            Try

                'Utils.Decls.INFOCENTRE_SERVICE_TK.FillServiceRowSEByCode( _
                '    Utils.Decls.INFOCENTRE_SERVICE_ROW_SE, _
                '    Security.Decrypt(SysInfo.ReadShareSysInfo(CommDecl.SVN_INFO_CENTRE_SERVICE_CODE)))
            Catch ex As System.Net.Sockets.SocketException
                If CommTK.FBoolean(SysInfo.ReadLocalSysInfo("Debugging")) = False Then
                    Me.SimpleButton_Login.Enabled = False
                End If
                Me.ShowStatusMessage(RExpXService.Decls.MSG_ALERT_00017)
            Catch ex As Exception
                Me.ShowStatusMessage(ex.Message)

            End Try

            'Dim chooseBranchlist As New RExpXAuto.FTs.FT_M_HLG_POST_BRANCH                  

            'RExpXAuto.Facade.AfBizMaster.FillFT_M_HLG_POST_BRANCH(Nothing, chooseBranchlist)
            'Me.LookUpEdit_CurrentDefaultBranch.Properties.DataSource = chooseBranchlist 

        End Sub

        Protected Overrides Function AttempHandleLoginException(ByVal ex As Exception) As String

            Return String.Empty

        End Function

        Public Overrides Sub AfterLogin()

            CommDecl.SYSTEM_START_RUNNING_TIME = RExpXService.Facade.OpSysConfig.GetServerTime()

            'RExpXService.Facade.OpBizMaster.InitDefaultInnerRelativeInfo()
            '
            '

            'Utils.TK.GetBarcodeOrder()


        End Sub

        Protected Overrides Sub DoSetMainForm()

            Me._baseMainForm = New MainForm()

        End Sub
        Protected Overrides Function CustomValidateLogin() As Boolean

            'If <Invalid happens> Then
            '     Return False
            'End If

            Return True

        End Function


        Protected Overrides Sub DoUpgradeXDB()

            Dim dbInitializor As RExpXAuto.XDB.DBInitializor
            If RExpXAuto.Decls.CURRENT_DB_TYPE <> XL.DB.DBDecl.DBType.Remoting Then
                dbInitializor = New RExpXAuto.XDB.DBInitializor
            Else
                dbInitializor = CType(Activator.GetObject(GetType(RExpXAuto.XDB.DBInitializor), _
                    String.Format("tcp://{0}/DBInitializor.remote", _
                        SysInfo.ReadLocalSysInfo(CommDecl.XLSLVN_SYSTEM_REMOTE_SERVICE_URL))), RExpXAuto.XDB.DBInitializor)
            End If

            dbInitializor.DoInitialize(True, False)

            RExpXAuto.Decls.CONNECTION_STRING = XL.DB.DBDecl.CurrentConnectionString
            RExpXAuto.Decls.CURRENT_DB_TYPE = XL.DB.DBDecl.CurrentDatabaseType
            RExpXAuto.Decls.REMOTE_DB_TYPE = XL.DB.DBDecl.CurrentDatabaseType


        End Sub

        Public Overrides Sub DoDownloadOfflineData()

            TK.DownloadOffLineData()

        End Sub

        Protected Overrides Sub DoSetXFormTransaction()

            Me._trWriteSysInfo = AddressOf RExpXService.Facade.OpSysConfig.SetSysValue
            Me._trReadSysInfo = AddressOf RExpXService.Facade.OpSysConfig.GetSysValue

            XL.Win.XForm.XFormTK.SetTrGetServerTime(AddressOf RExpXService.Facade.OpSysConfig.GetServerTime)

            XL.Win.XForm.XFormTK.SetTrGetSecureRow(AddressOf RExpXService.Facade.OpSysConfig.GetSecureRow)
            XL.Win.XForm.XFormTK.SetTrGetSecureList(AddressOf RExpXService.Facade.OpSysConfig.GetSecureList)
            XL.Win.XForm.XFormTK.SetTrCreateSecureInfo(AddressOf RExpXService.Facade.OpSysConfig.CreateSecureInfo)
            XL.Win.XForm.XFormTK.SetTrReviseSecureInfo(AddressOf RExpXService.Facade.OpSysConfig.ReviseSecureInfo)
            XL.Win.XForm.XFormTK.SetTrDeleteSecureInfo(AddressOf RExpXService.Facade.OpSysConfig.DeleteSecureInfo)

            XL.Win.XForm.XFormTK.SetTrGetUserRow(AddressOf RExpXService.Facade.OpSysConfig.GetUserRow)
            XL.Win.XForm.XFormTK.SetTrGetUserList(AddressOf RExpXService.Facade.OpSysConfig.GetUserList)
            XL.Win.XForm.XFormTK.SetTrCreateUserInfo(AddressOf RExpXService.Facade.OpSysConfig.CreateUserInfo)
            XL.Win.XForm.XFormTK.SetTrReviseUserInfo(AddressOf RExpXService.Facade.OpSysConfig.ReviseUserInfo)
            XL.Win.XForm.XFormTK.SetTrDeleteUserInfo(AddressOf RExpXService.Facade.OpSysConfig.DeleteUserInfo)

            XL.Win.XForm.XFormTK.SetTrValidateUserPassword(AddressOf RExpXService.Facade.OpSysConfig.ValidateUserPassword)
            XL.Win.XForm.XFormTK.SetTrValidateUserNamePassword(AddressOf RExpXService.Facade.OpSysConfig.ValidateUserNamePassword)

            XL.Win.XForm.XFormTK.SetTrReviseCommonItemClassifyInfo(AddressOf RExpXService.Facade.OpSysConfig.ReviseCommonItemClassifyInfo)
            XL.Win.XForm.XFormTK.SetTrCreateCommonItem(AddressOf RExpXService.Facade.OpSysConfig.CreateCommonItem)
            XL.Win.XForm.XFormTK.SetTrReviseCommonItem(AddressOf RExpXService.Facade.OpSysConfig.ReviseCommonItemInfo)
            XL.Win.XForm.XFormTK.SetTrIsCommonItemInUse(AddressOf RExpXService.Facade.OpSysConfig.IsCommonItemInUse)
            XL.Win.XForm.XFormTK.SetTrGetCommonItemList(AddressOf RExpXService.Facade.OpSysConfig.GetCommonItemList)
            XL.Win.XForm.XFormTK.SetTRGetCommonItemClassifyRow(AddressOf RExpXService.Facade.OpSysConfig.GetCommonItemClassifyRow)
            XL.Win.XForm.XFormTK.SetTrGetCommonItemClassifyList(AddressOf RExpXService.Facade.OpSysConfig.GetCommonItemClassifyList)
            XL.Win.XForm.XFormTK.SetTrDeleteCommonItem(AddressOf RExpXService.Facade.OpSysConfig.DeleteCommonItem)
            XL.Win.XForm.XFormTK.SetTrGetCommonItemRow(AddressOf RExpXService.Facade.OpSysConfig.GetCommonItemRow)
            XL.Win.XForm.XFormTK.SetTrCreateCommonItemClassify(AddressOf RExpXService.Facade.OpSysConfig.CreateCommonItemClassify)
            XL.Win.XForm.XFormTK.SetTrCreateFixedCommonItem(AddressOf RExpXService.Facade.OpSysConfig.CreateFixedCommonItem)
            XL.Win.XForm.XFormTK.SetTrGetCommonItemFlagList(AddressOf RExpXService.Facade.OpSysConfig.GetCommonItemFlagList)
            XL.Win.XForm.XFormTK.SetTrDeleteCommonItemClassifyAndItemExcludingNames(AddressOf RExpXService.Facade.OpSysConfig.DeleteCommonItemClassifyAndItemExcludingNames)
            XL.Win.XForm.XFormTK.SetTrDeleteCommonItemOfClassifyExcludingValues(AddressOf RExpXService.Facade.OpSysConfig.DeleteCommonItemOfClassifyExcludingValues)
            XL.Win.XForm.XFormTK.SetTrAttemptCreateDefaultAuthority(AddressOf RExpXService.Facade.OpSysConfig.AttemptCreateDefaultAuthority)
            XL.Win.XForm.XFormTK.SetTrGetSuperSecureID(AddressOf RExpXService.Facade.OpSysConfig.GetSuperSecureID)

            XL.Win.XForm.XFormTK.SetTrReviseCommonItemMeaningLanguageByID(AddressOf RExpXService.Facade.OpSysConfig.ReviseCommonItemMeaningLanguageByID)
            XL.Win.XForm.XFormTK.SetTrReviseCommonItemMeaningLanguagebyCV(AddressOf RExpXService.Facade.OpSysConfig.ReviseCommonItemMeaningLanguageByCV)
            XL.Win.XForm.XFormTK.SetTrReviseCommonClassifyLanguage(AddressOf RExpXService.Facade.OpSysConfig.ReviseCommonClassifyLanguage)

            XL.Win.XForm.XFormTK.SetTrCreateLog(AddressOf RExpXService.Facade.OpSysConfig.CreateLog)
            XL.Win.XForm.XFormTK.SetTrDeleteLogData(AddressOf RExpXService.Facade.OpSysConfig.DeleteLogData)
            XL.Win.XForm.XFormTK.SetTrDeleteLogInfo(AddressOf RExpXService.Facade.OpSysConfig.DeleteLogInfo)
            XL.Win.XForm.XFormTK.SetTrGetLogRow(AddressOf RExpXService.Facade.OpSysConfig.GetLogRow)
            XL.Win.XForm.XFormTK.SetTrGetLogList(AddressOf RExpXService.Facade.OpSysConfig.GetLogList)
            XL.Win.XForm.XFormTK.SetTrExportLogExcel(AddressOf Utils.TK.ExportSLog)

            XL.Win.XForm.XFormTK.SetTrGetInformMessageRow(AddressOf RExpXService.Facade.OpSysConfig.GetInformMessageRow)
            XL.Win.XForm.XFormTK.SetTrGetInformMessageList(AddressOf RExpXService.Facade.OpSysConfig.GetInformMessageList)
            XL.Win.XForm.XFormTK.SetTrRenewInformMessage(AddressOf RExpXService.Facade.OpSysConfig.RenewInformMessage)
            XL.Win.XForm.XFormTK.SetTrDownloadSysConfig(AddressOf RExpXService.Facade.OpSysConfig.DownloadSysValueCache)
            XL.Win.XForm.XFormTK.SetTrDownloadSysCommonItemCache(AddressOf RExpXService.Facade.OpSysConfig.DownloadSysCommonItemCache)
            XL.Win.XForm.XFormTK.SetTrDownloadSysSecureUserCache(AddressOf RExpXService.Facade.OpSysConfig.DownloadSysSecureUserCache)

            XL.Win.XForm.XFormTK.SetTrRemoveUserAccountOccupication(AddressOf RExpXService.Facade.OpSysConfig.RemoveUserAccountOccupication)
            XL.Win.XForm.XFormTK.SetTrSweapUserAccountOccupication(AddressOf RExpXService.Facade.OpSysConfig.SweapUserAccountOccupication)

            XL.Win.XForm.XFormTK.SetTrGetUserOptionsBox(AddressOf Utils.TK.GetUserOptionsBox)
            XL.Win.XForm.XFormTK.SetTrGetSecureOptionsBox(AddressOf Utils.TK.GetSecureOptionsBox)

            WinDecl.WinTrTCPResponse = AddressOf Utils.TCPResponsor.DoResponse
        End Sub

    End Class

End Namespace

